Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INFRA] Publish schema to Javascript Registry (https://jsr.io/@bids/schema) on changes and releases #1899

Merged
merged 5 commits into from
Aug 26, 2024

Conversation

effigies
Copy link
Collaborator

This PR adds a GitHub action that will push dev versions and release versions to https://jsr.io/@bids/schema.

I have been testing this for use in the BIDS validator. Currently we are able to load the schema from the registry via:

import { default as schema } from 'jsr:@bids/schema@0.0.202408200837/schema' with { type: 'json' }

We are also able to load the type of the schema with:

import type { Metaschema } from 'jsr:@bids/schema@0.0.202408200837/metaschema'
import type { Context }  from 'jsr:@bids/schema@0.0.202408200837/context'

The version scheme will be {schema.schema_version} if the version is a full release (X.Y.Z), and {schema.schema_version}.{serial}+{hash} for development versions.

The serial number is purely to ensure that development versions of the schema can be ordered, and is derived by parsing the previous version. The purpose of the hash is to help make clear when the content of the schema changes. It currently uses sha256sum schema.json | head -c 7, but I think a more useful hash would probably be the latest commit to touch the schema: git log -n 1 --pretty=%h src/schema/.


This PR incidentally changes the name of the Metaschema type to just Schema, so schema will have type Schema.

@effigies effigies added infrastructure schema Issues related to the YAML schema representation of the specification. Patch version release. labels Aug 21, 2024
@effigies
Copy link
Collaborator Author

Before merging, I would patch in:

diff --git a/.github/workflows/publish_schema.yml b/.github/workflows/publish_schema.yml
index d50ba7f3..b2895664 100644
--- a/.github/workflows/publish_schema.yml
+++ b/.github/workflows/publish_schema.yml
@@ -4,7 +4,6 @@ on:
   push:
     branches:
       - "master"
-      - "jsr/*"
     tags:
       - "schema-*"
 
@@ -22,6 +21,10 @@ env:
   GIT_COMMITTER_NAME: BIDS CI
   GIT_COMMITTER_EMAIL: bids.maintenance@gmail.com
 
+permissions:
+  contents: write
+  id-token: write
+
 jobs:
   publish:
     runs-on: ubuntu-latest
@@ -76,8 +79,9 @@ jobs:
             jq ".version = \"$VERSION\"" jsr.json > tmp.json && mv tmp.json jsr.json
             git add jsr.json schema.json context.ts metaschema.ts
             git commit -m "Update schema JSR distribution"
+            git push
           fi
       - name: Publish to JSR
         if: success()
         run: |
-          npx jsr publish --dry-run
+          npx jsr publish

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 87.23%. Comparing base (9377b20) to head (bd45643).

Files Patch % Lines
tools/schemacode/bidsschematools/__main__.py 0.00% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1899      +/-   ##
==========================================
- Coverage   88.10%   87.23%   -0.88%     
==========================================
  Files          16       16              
  Lines        1396     1410      +14     
==========================================
  Hits         1230     1230              
- Misses        166      180      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@effigies
Copy link
Collaborator Author

 Simulating publish of @bids/schema@0.11.1-dev.1+e5db69d6 with files:
   file:///home/runner/work/bids-specification/bids-specification/LICENSE (18.25KB)
   file:///home/runner/work/bids-specification/bids-specification/context.ts (8.46KB)
   file:///home/runner/work/bids-specification/bids-specification/jsr.json (191B)
   file:///home/runner/work/bids-specification/bids-specification/metaschema.ts (20.11KB)
   file:///home/runner/work/bids-specification/bids-specification/schema.json (450.74KB)

@effigies effigies marked this pull request as ready for review August 21, 2024 15:04
@effigies effigies merged commit c23fa9f into master Aug 26, 2024
24 of 25 checks passed
@effigies effigies deleted the jsr/publish-schema branch August 26, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure schema Issues related to the YAML schema representation of the specification. Patch version release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants